<template>
  <div style="overflow-y: auto;height: 90vh">
    <el-form :inline="true">
      <el-form-item label="地址搜索">
        <my-input v-model="keyword"></my-input>
      </el-form-item>
      <el-form-item label="路线从">
        <my-input v-model="start"></my-input>
      </el-form-item>
      <el-form-item label="路线至">
        <my-input v-model="end"></my-input>
      </el-form-item>
    </el-form>
    <baidu-map ak="GZ90Fko7YN87VxKPDi1ZCsGbYFhmREZ2" id="testMap" @ready="mapReady" :center="city">
      <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
      <bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation>
      <bm-city-list anchor="BMAP_ANCHOR_TOP_LEFT"></bm-city-list>
      <bm-panorama></bm-panorama>
      <bm-local-search v-show="city.trim() != ''" :keyword="keyword" :auto-viewport="true" :location="city" class="searchResult"></bm-local-search>
      <bm-transit :start="start" :end="end" :auto-viewport="true" :location="city" class="searchResult"></bm-transit>
    </baidu-map>
  </div>
</template>

<script>
  import MyInput from "../../../common/my-input";
  import BaiduMap from 'vue-baidu-map/components/map/Map';

  export default {
    name: "test",
    components: {
      'MyInput': MyInput,
      'BaiduMap': BaiduMap
    },
    data(){
      return{
        city: '沈阳',
        point: '',
        keyword: '',
        start: '',
        end: ''
      }
    },
    methods:{
      mapReady({ BMap, map }){
        // 选择一个经纬度作为中心点
        this.point = new BMap.Point(113.27, 23.13);
        map.centerAndZoom(this.point, 12);
      }
    }
  }
</script>

<style scoped>
  #testMap{
    height: 80vh;
    width: calc(100vw - 350px);
    margin: 0 auto;
    position: relative;
  }
  .searchResult{
    position: absolute;
    width: 30vw;
    height: 40vh;
    left: 0;
    top: 0;
  }
</style>
